<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');?>
<!-- thong ke -->
<div class="myclear">
	<!-- mbd-440 -->
	<div class="mbd-440 marright10">						
		<table class="tbl-list DataTable" width="100%" id="allbannerdetail" cellpadding="0" cellspacing="0" border="1" id="table">
        <thead>
			<tr>
				<th class="td-label">
					<b><?php echo $bannerdetail_lang['date']?></b>
				</th>
				
				<th class="td-label text-right">
					<b>Click</b>
				</th>
				
				<th class="td-label text-right">
					<b>Impression</b>
				</th>
				
				<th class="td-label text-right">
					<b>Unique Visitor</b>
				</th>
				
				<th class="td-label text-right">
					<b>CTR %</b>
				</th>
				
				<th class="td-label text-right">
					<b>Tiền sử dụng </b>(VND)
				</th>
			</tr>
        </thead>
        <tbody>
            <?php $index=1;
            $spent=0;
            foreach($bannerdetail as $bn)
            { 
                $bgcolor = ($index%2==0)?'class="bg-color-gray"':'';
            ?>
			<tr <?php echo $bgcolor?>>
				<td>
					<p class="mbd-sta-date">
						<?php echo $bn['clickdate'];?>
					</p>
				</td>
				<td>
					<p class="mbd-sta-click">
						<?php echo number_format($bn['clicks']);?>
					</p>
				</td>
				<td>
					<p class="mbd-sta-imp">
						<?php echo number_format($bn['impressions']);?>
					</p>
				</td>
				<td>
					<p class="mbd-sta-uvisitor">
						<?php echo number_format($bn['uviews']);?>
					</p>
				</td>
				<td>
					<p class="mbd-sta-ctr">
						<?php echo $bn['CTR'];?>
					</p>
				</td>
				<td>
					<p class="mbd-sta-money">
						<?php echo number_format($bn['money']);?>
					</p>
				</td>
			</tr>
			<?php
            }
            ?>
        </tbody>
        <tr>
            <td>
                <p class="mbd-sta-date">
                    <b><?php echo 'Tổng cộng';?></b>
                </p>
            </td>
            <td>
				<p class="mbd-sta-click">
					<b><?php echo number_format($total[0]['clicks']);?></b>
				</p>
			</td>
            <td>
				<p class="mbd-sta-imp">
					<b><?php echo number_format($total[0]['views']);?></b>
				</p>
			</td>
            <td>
				<p class="mbd-sta-uvisitor">
					<b><?php echo number_format($total[0]['uviews']);?></b>
				</p>
			</td>
            <td>
				<p class="mbd-sta-ctr">
					<b><?php echo $total[0]['CTR'];?></b>
				</p>
			</td>
			<td>
				<p class="mbd-sta-money">
					<b><?php echo number_format($total[0]['money']);?></b>
				</p>
			</td>
        </tr>
		</table>
		
        <div id="pager" style="font-family: tahoma;border: solid 1px #D6D6D6;width: 165px;float: right; margin-top: 10px;background-color: white;padding:3px 10px 3px 10px">
        	<form>
                <span style="vertical-align: middle;"><?php echo $bannerdetail_lang['page'];?></span>
                <input type="text" class="pagedisplay" size="2" style="border:0;vertical-align: middle;"/>
        		<img src="/images/imgpre.gif" class="prev" id="prev" style="vertical-align: middle;"/>
        		<img src="/images/imgnext.gif" class="next" id="next" style="vertical-align: middle;"/>
        		<select class="pagesize" style="vertical-align: middle;border: 0 none;background: #fff;">
        			<option selected="selected" value="10">10</option>
        			<option value="20">20</option>
        			<option value="30">30</option>
        			<option  value="40">40</option>
        		</select>
        	</form>
        </div>		
	</div> <!-- end .mbd-440 -->
	
	<!-- mbd-300 -->
	<div class="mbd-300">	
		
		<div class="mbd-breview">
			<p class="bold">
				<?php echo $info[0]['bannername'];?>
			</p>
			
			<p class="breview-box-domain">
				<?php echo $info[0]['url'];?>
			</p>
			
			<div class="myclear padtop5">
				<p class="breview-box-img">
					<img alt="" src="<?php echo $info[0]['filepath'];?>" />
				</p>
				<div class="breview-box-bodytext">
					<?php echo $info[0]['description'];?>
				</div>
				<!-- important. fix for ie 6. Don't remove -->
				<!--[if IE 6]><br class="clearboth" /><![endif]-->
			</div>
		</div>
		
		<div class="martop10 myclear">
			<a href="<?php echo site_url('bannerdetail/trackBanner?bannerid='.$bannerdetailid.'&fromdate='.$fromdate.'&todate='.$todate);?>" class="graybtn">
				<span><?php echo $bannerdetail_lang['search']?></span>
			</a>
			<a href="<?php echo site_url('home/editAd/'.$bannerdetailid);?>" class="graybtn marleft20">
				<span><?php echo $bannerdetail_lang['editBanner']?></span>
			</a>
			
		</div>
		
	</div> <!-- end .mbd-300 -->
	
	<!-- important. fix for ie 6. Don't remove -->
	<!--[if IE 6]><br class="clearboth" /><![endif]-->
</div>
<!-- end thong ke -->

<div class="mbd-chartbox myclear">
	
	<div class="myclear marleft20">
		<a class="graybtn marright5">
			<span <?php echo ($type==0)? 'class="curr"':'' ;?> onclick="ajax_chart(0);" id="clicks">Clicks</span>
		</a>
		
		<a class="graybtn">
			<span <?php echo ($type==1)? 'class="curr"':'' ;?> onclick="ajax_chart(1);" id="impressions">Impressions</span>
		</a>
        <a class="marleft10">
			<img id="loading" src="/images/ajaxLoading.gif" class="martop5 ver-middle" style="display: none;"/>
		</a>
	</div>
    <div id="my_chart"></div>
</div>
<script type="text/javascript">
$(document).ready(function() { 
    <?php if(count($bannerdetail) >0 )
    {
    ?>
    jQuery.tablesorter.addParser({
          id: "fancyNumber",
          is: function(s) {
            return false;
          },
          format: function(s) {
            return parseFloat( s.replace(/,/g,'') );
          },
          type: "numeric"
        });
     	$('#table').tablesorter({headers: 
        { 
            1: {sorter:'fancyNumber'},
            2: {sorter:'fancyNumber'},
            3: {sorter:'fancyNumber'},
            5: {sorter:'fancyNumber'}
        }
        }).tablesorterPager({container: $("#pager")});
    <?php
    }
    ?>
});
$('#date').DatePicker({
        format: 'd/m/Y',
        date: ['<?php echo date('d/m/Y',strtotime($fromdate));?>','<?php echo date('d/m/Y',strtotime($todate));?>'],
        current: '<?php echo date('d/m/Y');?>',
        calendars: 2,
        mode: 'range',
        starts: 1, 
        onChange: function(formated, dates) 
        {
            $('#date').val(formated.join(' <?php echo $bannerdetail_lang['to']?> '));
            $('#date').DatePickerHide();
            var arrTime = formated.toString().split(',');
            var fromdate = arrTime[0];
            var todate = arrTime[1];
            var strReplace="/";
            fromdate=fromdate.replace(/\//g,'-');
            todate=todate.replace(/\//g,'-');
            var strURL="<?php echo site_url('bannerdetail/timeFilter/?bannerid='.$bannerdetailid);?>&fromdate="+fromdate+"&todate="+todate;
            getAjax(strURL,"",'#campaigndiv');
        }
    });
    ajax_chart(0);
</script>